import 'package:yaml/yaml.dart';

class AssetConfig {
  String? package;
  String? name;
  List<AssetSource>? source;

  AssetConfig({this.package, this.name, this.source});

  factory AssetConfig.fromYaml(YamlMap? yamlMap) {
    return AssetConfig(
        package: yamlMap?['package'] ?? 'lib/resource',
        name: yamlMap?['name'] ?? 'resources',
        source: (yamlMap?['source'] as YamlList?)?.map((element) => AssetSource.fromYaml(element)).toList());
  }
}

class AssetSource {
  String? path;
  AssetSourceDark? dark;

  AssetSource({this.path, this.dark});

  factory AssetSource.fromYaml(YamlMap? yamlMap) {
    return AssetSource(path: yamlMap?['path'], dark: AssetSourceDark.fromYaml(yamlMap?['dark']));
  }
}

class AssetSourceDark {
  bool enable = true;
  String? path;
  String? import;
  String? condition;

  AssetSourceDark({this.path, required this.enable, this.import, this.condition});

  factory AssetSourceDark.fromYaml(YamlMap? yamlMap) {
    return AssetSourceDark(path: yamlMap?['path'],
        enable: yamlMap?['enable'] ?? true,
        import: yamlMap?['import'],
        condition: yamlMap?['condition']
    );
  }
}
